package ro.cdv.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;

import ro.cdv.model.Product;

@Service
public class ProductService {

    private Map<Integer, Product> storage = new HashMap<Integer, Product>();

    public ProductService() {
    	storage.put(1, new Product(1, "Pen", 0.9D));
        storage.put(2, new Product(2, "Pencil", 0.5D));
        storage.put(3, new Product(3, "Stickers", 1.3D));
    }

    public Product getProductById(Integer id) {
        return storage.get(id);
    }

    public List<Product> getProducts() {
        List<Product> list = new ArrayList<Product>();
        list.addAll(storage.values());
        return list;
    }

}

